Skip to content

Commit

Permalink
Add noto font to render mandarin characters
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Chamberland <[email protected]>
  • Loading branch information
chxmberland committed Jul 19, 2024
1 parent a9c735d commit 1acd41a
Show file tree
Hide file tree
Showing 5 changed files with 660,057 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/ui/TwkGLText/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SET(_target
)

SET(_sources
GLT.cpp TwkGLText.cpp defaultFont.cpp
GLT.cpp TwkGLText.cpp defaultFont.cpp noto.cpp
)

FIND_PACKAGE(OpenGL REQUIRED)
Expand Down
3 changes: 2 additions & 1 deletion src/lib/ui/TwkGLText/GLT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//******************************************************************************
#include <TwkGLText/TwkGLText.h>
#include <TwkGLText/defaultFont.h>
#include <TwkGLText/noto.h>
#include <TwkGLText/GLT.h>
#include <FTGL/ftgl.h>
#include <TwkExc/TwkExcException.h>
Expand Down Expand Up @@ -41,7 +42,7 @@ void gltFace(const std::string& fontName, size_t fontSize)

if (!face)
{
face = new GLTFace(default_font, 67548);
face = new GLTFace(notoFont, notoFontSize);
face->FaceSize(fontSize);
cache[d] = face;
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/ui/TwkGLText/TwkGLText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <iostream>
#include <stl_ext/string_algo.h>
#include <TwkGLText/defaultFont.h>
#include <TwkGLText/noto.h>
#include <iterator>
#include <pthread.h>

Expand Down Expand Up @@ -147,7 +148,7 @@ Context GLtext::newContext()
}

if ((*ctx->fonts[ctx->fontName]).size() <= ctx->size) (*ctx->fonts[ctx->fontName]).resize(ctx->size+1);
if (!(*ctx->fonts[ctx->fontName])[ctx->size]) (*ctx->fonts[ctx->fontName])[ctx->size] = newFont(default_font, 67548);
if (!(*ctx->fonts[ctx->fontName])[ctx->size]) (*ctx->fonts[ctx->fontName])[ctx->size] = newFont(notoFont, notoFontSize);
(*ctx->fonts[ctx->fontName])[ctx->size]->FaceSize(ctx->size);
ctx->initialized = true;

Expand Down Expand Up @@ -194,7 +195,7 @@ void GLtext::init()
(*ctx->fonts[ctx->fontName]).resize(ctx->size+1);
}
if (!(*ctx->fonts[ctx->fontName])[ctx->size]) {
(*ctx->fonts[ctx->fontName])[ctx->size] = newFont(default_font, 67548);
(*ctx->fonts[ctx->fontName])[ctx->size] = newFont(notoFont, notoFontSize);
(*ctx->fonts[ctx->fontName])[ctx->size]->FaceSize(ctx->size);
}
ctx->initialized = true;
Expand Down
14 changes: 14 additions & 0 deletions src/lib/ui/TwkGLText/TwkGLText/noto.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//******************************************************************************
// Copyright (c) 2024 Autodesk Inc. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
//******************************************************************************

#ifndef __NOTO_H__
#define __NOTO_H__

extern const unsigned char notoFont[];
const unsigned int notoFontSize = 10560380;

#endif // End #ifdef __NOTO_H__
Loading

0 comments on commit 1acd41a

Please sign in to comment.