Browse Source

make maxTextureSize part of request, remove window global, buffer guard on size

master
Odilitime 5 years ago
parent
commit
ac85f54c8b
  1. 13
      src/graphics/text/TextRasterizer.cpp
  2. 2
      src/graphics/text/TextRasterizer.h

13
src/graphics/text/TextRasterizer.cpp

@ -59,6 +59,10 @@ std::unique_ptr<std::pair<int, int>> TextRasterizer::size(const rasterizationReq @@ -59,6 +59,10 @@ std::unique_ptr<std::pair<int, int>> TextRasterizer::size(const rasterizationReq
std::cout << "TextRasterizer::size - x [" << static_cast<int>(request.startX) << "] requested outside of window width [" << static_cast<int>(request.availableWidth)<< "] for text[" << request.text << "]" << std::endl;
return nullptr;
}
if (!buffer) {
std::cout << "TextRasterizer::rasterize - no font loaded" << std::endl;
return nullptr;
}
unsigned int glyphCount;
@ -180,12 +184,11 @@ std::unique_ptr<rasterizationResponse> TextRasterizer::rasterize(const rasteriza @@ -180,12 +184,11 @@ std::unique_ptr<rasterizationResponse> TextRasterizer::rasterize(const rasteriza
std::cout << "TextRasterizer::rasterize - x [" << static_cast<int>(request.startX) << "] requested outside of window width [" << static_cast<int>(request.availableWidth)<< "] for text[" << request.text << "]" << std::endl;
return nullptr;
}
unsigned int glyphCount;
if (!buffer) {
std::cout << "TextRasterizer::rasterize - no font loaded" << std::endl;
return nullptr;
}
unsigned int glyphCount;
hb_buffer_reset(buffer);
hb_buffer_set_direction(buffer, HB_DIRECTION_LTR);
@ -328,9 +331,9 @@ std::unique_ptr<rasterizationResponse> TextRasterizer::rasterize(const rasteriza @@ -328,9 +331,9 @@ std::unique_ptr<rasterizationResponse> TextRasterizer::rasterize(const rasteriza
//std::cout << "xd: " << static_cast<int>(response->x1-response->x0) << " yd: " << static_cast<int>(response->y0-response->y1) << std::endl;
//std::cout << "Requesting texture of " << response->textureWidth << "x" << response->textureHeight << "max: " << win->maxTextureSize << std::endl;
if (response->textureHeight > static_cast<unsigned int>(win->maxTextureSize)) {
std::cout << "Truncating text texture to fit in your video card" << std::endl;
response->textureHeight = static_cast<unsigned int>(win->maxTextureSize);
if (response->textureHeight > request.maxTextureSize) {
std::cout << "Truncating text texture height to fit in your video card: " << response->textureHeight << ">" << request.maxTextureSize << std::endl;
response->textureHeight = request.maxTextureSize;
}
// texture coords

2
src/graphics/text/TextRasterizer.h

@ -40,6 +40,7 @@ struct rasterizationRequest { @@ -40,6 +40,7 @@ struct rasterizationRequest {
int sourceStartX = 0; // start reading text source at and place at destination 0
int sourceStartY = 0;
bool noWrap = false; // different than overflow but related
unsigned int maxTextureSize = 0;
};
struct rasterizationResponse {
@ -77,7 +78,6 @@ public: @@ -77,7 +78,6 @@ public:
hb_font_t *font;
hb_buffer_t *buffer;
std::unique_ptr<FT_Face> face;
Window *win;
};
#endif

Loading…
Cancel
Save