Changeset - r28503:4b34363e7f47
[Not reviewed]
master
0 1 0
Patric Stout - 11 months ago 2024-01-18 08:36:48
truebrain@openttd.org
Codechange: [HarfBuzz] hb-ft will set the scaling on its own
1 file changed with 1 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/gfx_layout_icu.cpp
Show inline comments
 
@@ -23,13 +23,13 @@
 

	
 
#include <hb.h>
 
#include <hb-ft.h>
 

	
 
#include "safeguards.h"
 

	
 
/** harfbuzz doesn't use floats, so we need a value to scale position with to get sub-pixel precision. */
 
/** HarfBuzz FreeType integration sets the font scaling, which is always in 1/64th of a pixel. */
 
constexpr float FONT_SCALE = 64.0;
 

	
 
/**
 
 * Helper class to store the information of all the runs of a paragraph in.
 
 *
 
 * During itemization, more and more information is filled in.
 
@@ -154,13 +154,12 @@ ICUParagraphLayout::ICUVisualRun::ICUVis
 
 * @param buff The buffer of which a partial (depending on start/length of the run) will be shaped.
 
 * @param length The length of the buffer.
 
 */
 
void ICURun::Shape(UChar *buff, size_t buff_length)
 
{
 
	auto hbfont = hb_ft_font_create_referenced(*(static_cast<const FT_Face *>(font->fc->GetOSHandle())));
 
	hb_font_set_scale(hbfont, this->font->fc->GetFontSize() * FONT_SCALE, this->font->fc->GetFontSize() * FONT_SCALE);
 

	
 
	/* ICU buffer is in UTF-16. */
 
	auto hbbuf = hb_buffer_create();
 
	hb_buffer_add_utf16(hbbuf, reinterpret_cast<uint16_t *>(buff), buff_length, this->start, this->length);
 

	
 
	/* Set all the properties of this segment. */
0 comments (0 inline, 0 general)