From 94a9a28de16badb75e66a60efca3b01d31cc0fc6 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 4 Nov 2021 12:48:01 +0800 Subject: * text anchor --- Runtime/GUI/Font.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'Runtime/GUI/Font.cpp') diff --git a/Runtime/GUI/Font.cpp b/Runtime/GUI/Font.cpp index 1993126..4425b17 100644 --- a/Runtime/GUI/Font.cpp +++ b/Runtime/GUI/Font.cpp @@ -7,11 +7,14 @@ using namespace character; -//https://unicode-table.com/en/#cjk-unified-ideographs-extension-a -//https://learnopengl.com/In-Practice/Text-Rendering -//https://www.zhihu.com/question/294660079 -//https://baike.baidu.com/item/%E5%9F%BA%E6%9C%AC%E5%A4%9A%E6%96%87%E7%A7%8D%E5%B9%B3%E9%9D%A2/10788078 -//https://stackoverflow.com/questions/27331819/whats-the-difference-between-a-character-a-code-point-a-glyph-and-a-grapheme +/* +* http://madig.github.io/freetype-web/documentation/tutorial/ +* https://unicode-table.com/en/#cjk-unified-ideographs-extension-a +* https://learnopengl.com/In-Practice/Text-Rendering +* https://www.zhihu.com/question/294660079 +* https://baike.baidu.com/item/%E5%9F%BA%E6%9C%AC%E5%A4%9A%E6%96%87%E7%A7%8D%E5%B9%B3%E9%9D%A2/10788078 +* https://stackoverflow.com/questions/27331819/whats-the-difference-between-a-character-a-code-point-a-glyph-and-a-grapheme +*/ static std::string s_FontError; @@ -161,7 +164,7 @@ bool Font::RenderCharacter(character::Unicode codepoint, int pixelSize) int h = m_FTFace->glyph->bitmap.rows; const unsigned char* pixels = m_FTFace->glyph->bitmap.buffer; - if (pixels != NULL) // 非空格 + if (pixels != NULL) // 有些字体中space、tab没有字形的 { s_PixelBuffer.resize(w * h); if (m_FTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) @@ -183,7 +186,7 @@ bool Font::RenderCharacter(character::Unicode codepoint, int pixelSize) memcpy(&s_PixelBuffer[0], pixels, s_SizePerPixel * w * h); } - //TextHelper::print_glyph(&s_PixelBuffer[0], w, h); + TextHelper::print_glyph(&s_PixelBuffer[0], w, h); GlyphAtals* atlas = RequestAtlas(pixelSize, Internal::Vector2(w, h)); Assert(atlas); @@ -208,7 +211,7 @@ bool Font::RenderCharacter(character::Unicode codepoint, int pixelSize) character.position = rect; character.bearing = Internal::Vector2(m_FTFace->glyph->bitmap_left, m_FTFace->glyph->bitmap_top); } - else // 空格 + else // space、tab { character.atlas = FONT_NOT_IN_ATLAS_PLACEHOLDER; character.position = Rect(0,0,0,0); @@ -295,7 +298,7 @@ GlyphAtals* Font::RequestAtlas(int pixelSize, Internal::Vector2 preferSize) Texture* Font::CreateAtlas() { TextureSetting setting; - setting.filterMode = ETextureFilterMode::Linear; + setting.filterMode = ETextureFilterMode::Nearest; setting.wrapMode = ETextureWrapMode::Clamp; setting.format = ETextureFormat::R8; setting.type = ETextureType::TEX_2D; -- cgit v1.1-26-g67d0