mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
New font and italic in python keywords (#232)
This commit is contained in:
@@ -24,6 +24,105 @@ constexpr KDColor BackgroundColor = Palette::CodeBackground;
|
||||
constexpr KDColor HighlightColor = Palette::CodeBackgroundSelected;
|
||||
constexpr KDColor AutocompleteColor = KDColor::RGB24(0xC6C6C6); // TODO Palette change
|
||||
|
||||
bool isItalic(mp_token_kind_t tokenKind) {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()) {
|
||||
return false;
|
||||
}
|
||||
if (tokenKind == MP_TOKEN_STRING) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static_assert(MP_TOKEN_ELLIPSIS + 1 == MP_TOKEN_KW_FALSE
|
||||
&& MP_TOKEN_KW_FALSE + 1 == MP_TOKEN_KW_NONE
|
||||
&& MP_TOKEN_KW_NONE + 1 == MP_TOKEN_KW_TRUE
|
||||
&& MP_TOKEN_KW_TRUE + 1 == MP_TOKEN_KW___DEBUG__
|
||||
&& MP_TOKEN_KW___DEBUG__ + 1 == MP_TOKEN_KW_AND
|
||||
&& MP_TOKEN_KW_AND + 1 == MP_TOKEN_KW_AS
|
||||
&& MP_TOKEN_KW_AS + 1 == MP_TOKEN_KW_ASSERT
|
||||
/* Here there are keywords that depend on MICROPY_PY_ASYNC_AWAIT, we do
|
||||
* not test them */
|
||||
&& MP_TOKEN_KW_BREAK + 1 == MP_TOKEN_KW_CLASS
|
||||
&& MP_TOKEN_KW_CLASS + 1 == MP_TOKEN_KW_CONTINUE
|
||||
&& MP_TOKEN_KW_CONTINUE + 1 == MP_TOKEN_KW_DEF
|
||||
&& MP_TOKEN_KW_DEF + 1 == MP_TOKEN_KW_DEL
|
||||
&& MP_TOKEN_KW_DEL + 1 == MP_TOKEN_KW_ELIF
|
||||
&& MP_TOKEN_KW_ELIF + 1 == MP_TOKEN_KW_ELSE
|
||||
&& MP_TOKEN_KW_ELSE + 1 == MP_TOKEN_KW_EXCEPT
|
||||
&& MP_TOKEN_KW_EXCEPT + 1 == MP_TOKEN_KW_FINALLY
|
||||
&& MP_TOKEN_KW_FINALLY + 1 == MP_TOKEN_KW_FOR
|
||||
&& MP_TOKEN_KW_FOR + 1 == MP_TOKEN_KW_FROM
|
||||
&& MP_TOKEN_KW_FROM + 1 == MP_TOKEN_KW_GLOBAL
|
||||
&& MP_TOKEN_KW_GLOBAL + 1 == MP_TOKEN_KW_IF
|
||||
&& MP_TOKEN_KW_IF + 1 == MP_TOKEN_KW_IMPORT
|
||||
&& MP_TOKEN_KW_IMPORT + 1 == MP_TOKEN_KW_IN
|
||||
&& MP_TOKEN_KW_IN + 1 == MP_TOKEN_KW_IS
|
||||
&& MP_TOKEN_KW_IS + 1 == MP_TOKEN_KW_LAMBDA
|
||||
&& MP_TOKEN_KW_LAMBDA + 1 == MP_TOKEN_KW_NONLOCAL
|
||||
&& MP_TOKEN_KW_NONLOCAL + 1 == MP_TOKEN_KW_NOT
|
||||
&& MP_TOKEN_KW_NOT + 1 == MP_TOKEN_KW_OR
|
||||
&& MP_TOKEN_KW_OR + 1 == MP_TOKEN_KW_PASS
|
||||
&& MP_TOKEN_KW_PASS + 1 == MP_TOKEN_KW_RAISE
|
||||
&& MP_TOKEN_KW_RAISE + 1 == MP_TOKEN_KW_RETURN
|
||||
&& MP_TOKEN_KW_RETURN + 1 == MP_TOKEN_KW_TRY
|
||||
&& MP_TOKEN_KW_TRY + 1 == MP_TOKEN_KW_WHILE
|
||||
&& MP_TOKEN_KW_WHILE + 1 == MP_TOKEN_KW_WITH
|
||||
&& MP_TOKEN_KW_WITH + 1 == MP_TOKEN_KW_YIELD
|
||||
&& MP_TOKEN_KW_YIELD + 1 == MP_TOKEN_OP_ASSIGN
|
||||
&& MP_TOKEN_OP_ASSIGN + 1 == MP_TOKEN_OP_TILDE,
|
||||
"MP_TOKEN order changed, so Code::PythonTextArea::TokenColor might need to change too.");
|
||||
if (tokenKind >= MP_TOKEN_KW_FALSE && tokenKind <= MP_TOKEN_KW_YIELD) {
|
||||
return true;
|
||||
}
|
||||
static_assert(MP_TOKEN_OP_TILDE + 1 == MP_TOKEN_OP_LESS
|
||||
&& MP_TOKEN_OP_LESS + 1 == MP_TOKEN_OP_MORE
|
||||
&& MP_TOKEN_OP_MORE + 1 == MP_TOKEN_OP_DBL_EQUAL
|
||||
&& MP_TOKEN_OP_DBL_EQUAL + 1 == MP_TOKEN_OP_LESS_EQUAL
|
||||
&& MP_TOKEN_OP_LESS_EQUAL + 1 == MP_TOKEN_OP_MORE_EQUAL
|
||||
&& MP_TOKEN_OP_MORE_EQUAL + 1 == MP_TOKEN_OP_NOT_EQUAL
|
||||
&& MP_TOKEN_OP_NOT_EQUAL + 1 == MP_TOKEN_OP_PIPE
|
||||
&& MP_TOKEN_OP_PIPE + 1 == MP_TOKEN_OP_CARET
|
||||
&& MP_TOKEN_OP_CARET + 1 == MP_TOKEN_OP_AMPERSAND
|
||||
&& MP_TOKEN_OP_AMPERSAND + 1 == MP_TOKEN_OP_DBL_LESS
|
||||
&& MP_TOKEN_OP_DBL_LESS + 1 == MP_TOKEN_OP_DBL_MORE
|
||||
&& MP_TOKEN_OP_DBL_MORE + 1 == MP_TOKEN_OP_PLUS
|
||||
&& MP_TOKEN_OP_PLUS + 1 == MP_TOKEN_OP_MINUS
|
||||
&& MP_TOKEN_OP_MINUS + 1 == MP_TOKEN_OP_STAR
|
||||
&& MP_TOKEN_OP_STAR + 1 == MP_TOKEN_OP_AT
|
||||
&& MP_TOKEN_OP_AT + 1 == MP_TOKEN_OP_DBL_SLASH
|
||||
&& MP_TOKEN_OP_DBL_SLASH + 1 == MP_TOKEN_OP_SLASH
|
||||
&& MP_TOKEN_OP_SLASH + 1 == MP_TOKEN_OP_PERCENT
|
||||
&& MP_TOKEN_OP_PERCENT + 1 == MP_TOKEN_OP_DBL_STAR
|
||||
&& MP_TOKEN_OP_DBL_STAR + 1 == MP_TOKEN_DEL_PIPE_EQUAL
|
||||
&& MP_TOKEN_DEL_PIPE_EQUAL + 1 == MP_TOKEN_DEL_CARET_EQUAL
|
||||
&& MP_TOKEN_DEL_CARET_EQUAL + 1 == MP_TOKEN_DEL_AMPERSAND_EQUAL
|
||||
&& MP_TOKEN_DEL_AMPERSAND_EQUAL + 1 == MP_TOKEN_DEL_DBL_LESS_EQUAL
|
||||
&& MP_TOKEN_DEL_DBL_LESS_EQUAL + 1 == MP_TOKEN_DEL_DBL_MORE_EQUAL
|
||||
&& MP_TOKEN_DEL_DBL_MORE_EQUAL + 1 == MP_TOKEN_DEL_PLUS_EQUAL
|
||||
&& MP_TOKEN_DEL_PLUS_EQUAL + 1 == MP_TOKEN_DEL_MINUS_EQUAL
|
||||
&& MP_TOKEN_DEL_MINUS_EQUAL + 1 == MP_TOKEN_DEL_STAR_EQUAL
|
||||
&& MP_TOKEN_DEL_STAR_EQUAL + 1 == MP_TOKEN_DEL_AT_EQUAL
|
||||
&& MP_TOKEN_DEL_AT_EQUAL + 1 == MP_TOKEN_DEL_DBL_SLASH_EQUAL
|
||||
&& MP_TOKEN_DEL_DBL_SLASH_EQUAL + 1 == MP_TOKEN_DEL_SLASH_EQUAL
|
||||
&& MP_TOKEN_DEL_SLASH_EQUAL + 1 == MP_TOKEN_DEL_PERCENT_EQUAL
|
||||
&& MP_TOKEN_DEL_PERCENT_EQUAL + 1 == MP_TOKEN_DEL_DBL_STAR_EQUAL
|
||||
&& MP_TOKEN_DEL_DBL_STAR_EQUAL + 1 == MP_TOKEN_DEL_PAREN_OPEN
|
||||
&& MP_TOKEN_DEL_PAREN_OPEN + 1 == MP_TOKEN_DEL_PAREN_CLOSE
|
||||
&& MP_TOKEN_DEL_PAREN_CLOSE + 1 == MP_TOKEN_DEL_BRACKET_OPEN
|
||||
&& MP_TOKEN_DEL_BRACKET_OPEN + 1 == MP_TOKEN_DEL_BRACKET_CLOSE
|
||||
&& MP_TOKEN_DEL_BRACKET_CLOSE + 1 == MP_TOKEN_DEL_BRACE_OPEN
|
||||
&& MP_TOKEN_DEL_BRACE_OPEN + 1 == MP_TOKEN_DEL_BRACE_CLOSE
|
||||
&& MP_TOKEN_DEL_BRACE_CLOSE + 1 == MP_TOKEN_DEL_COMMA
|
||||
&& MP_TOKEN_DEL_COMMA + 1 == MP_TOKEN_DEL_COLON
|
||||
&& MP_TOKEN_DEL_COLON + 1 == MP_TOKEN_DEL_PERIOD
|
||||
&& MP_TOKEN_DEL_PERIOD + 1 == MP_TOKEN_DEL_SEMICOLON
|
||||
&& MP_TOKEN_DEL_SEMICOLON + 1 == MP_TOKEN_DEL_EQUAL
|
||||
&& MP_TOKEN_DEL_EQUAL + 1 == MP_TOKEN_DEL_MINUS_MORE,
|
||||
"MP_TOKEN order changed, so Code::PythonTextArea::TokenColor might need to change too.");
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline KDColor TokenColor(mp_token_kind_t tokenKind) {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()) {
|
||||
return Palette::CodeText;
|
||||
@@ -255,7 +354,8 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
|
||||
BackgroundColor,
|
||||
selectionStart,
|
||||
selectionEnd,
|
||||
HighlightColor);
|
||||
HighlightColor,
|
||||
false);
|
||||
}
|
||||
if (UTF8Helper::CodePointIs(firstNonSpace, UCodePointNull)) {
|
||||
return;
|
||||
@@ -285,14 +385,16 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
|
||||
BackgroundColor,
|
||||
selectionStart,
|
||||
selectionEnd,
|
||||
HighlightColor);
|
||||
HighlightColor,
|
||||
false);
|
||||
}
|
||||
tokenLength = TokenLength(lex, tokenFrom);
|
||||
tokenEnd = tokenFrom + tokenLength;
|
||||
|
||||
// If the token is being autocompleted, use DefaultColor
|
||||
// If the token is being autocompleted, use DefaultColor/Font
|
||||
KDColor color = (tokenFrom <= autocompleteStart && autocompleteStart < tokenEnd) ? Palette::CodeText : TokenColor(lex->tok_kind);
|
||||
|
||||
bool font = (tokenFrom <= autocompleteStart && autocompleteStart < tokenEnd) ? false:isItalic(lex->tok_kind);
|
||||
|
||||
LOG_DRAW("Draw \"%.*s\" for token %d\n", tokenLength, tokenFrom, lex->tok_kind);
|
||||
drawStringAt(ctx, line,
|
||||
UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom),
|
||||
@@ -302,7 +404,8 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
|
||||
BackgroundColor,
|
||||
selectionStart,
|
||||
selectionEnd,
|
||||
HighlightColor);
|
||||
HighlightColor,
|
||||
font);
|
||||
|
||||
mp_lexer_to_next(lex);
|
||||
LOG_DRAW("Pop token %d\n", lex->tok_kind);
|
||||
@@ -325,7 +428,8 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
|
||||
BackgroundColor,
|
||||
selectionStart,
|
||||
selectionEnd,
|
||||
HighlightColor);
|
||||
HighlightColor,
|
||||
true);
|
||||
}
|
||||
|
||||
mp_lexer_free(lex);
|
||||
@@ -345,7 +449,8 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
|
||||
BackgroundColor,
|
||||
nullptr,
|
||||
nullptr,
|
||||
HighlightColor);
|
||||
HighlightColor,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class ListController;
|
||||
|
||||
class TextFieldFunctionTitleCell : public Shared::FunctionTitleCell, public Responder {
|
||||
public:
|
||||
TextFieldFunctionTitleCell(ListController * listController, Orientation orientation = Orientation::VerticalIndicator, const KDFont * font = KDFont::LargeFont);
|
||||
TextFieldFunctionTitleCell(ListController * listController, Orientation orientation = Orientation::VerticalIndicator, const KDFont * font = KDFont::ItalicLargeFont);
|
||||
TextField * textField() { return &m_textField; }
|
||||
void setEditing(bool editing);
|
||||
bool isEditing() const;
|
||||
|
||||
@@ -5,7 +5,8 @@ namespace Reader {
|
||||
|
||||
// List of available Symbols
|
||||
static constexpr char const * k_SymbolsCommands[] = {
|
||||
"times", "div", "forall", "partial", "exists", "pm", "approx", "infty", "neq", "equiv", "leq", "geq",
|
||||
"times", "div", "forall", "partial", "exists", "nexists", "pm", "approx", "infty", "neq", "equiv", "leq", "geq",
|
||||
"cap", "cup", "Cap", "Cup", "subset", "nsubset", "In", "Notin",
|
||||
"leftarrow", "uparrow", "rightarrow", "downarrow","leftrightarrow", "updownarrow", "Leftarrow", "Uparrow", "Rightarrow", "Downarrow",
|
||||
"nwarrow", "nearrow", "swarrow", "searrow", "in", "cdot", "cdots", "ldots",
|
||||
"Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Zeta", "Eta", "Theta", "Iota", "Kappa", "Lambda",
|
||||
@@ -19,7 +20,8 @@ namespace Reader {
|
||||
|
||||
// List of the available Symbol's CodePoints in the same order of the Symbol's list
|
||||
static constexpr uint32_t const k_SymbolsCodePoints[] = {
|
||||
0xd7, 0xf7, 0x2200, 0x2202, 0x2203, 0xb1, 0x2248, 0x221e, 0x2260, 0x2261, 0x2264, 0x2265,
|
||||
0xd7, 0xf7, 0x2200, 0x2202, 0x2203, 0x2204, 0xb1, 0x2248, 0x221e, 0x2260, 0x2261, 0x2264, 0x2265,
|
||||
0x2229, 0x222a, 0x22c2, 0x22c3, 0x2282, 0x2284, 0x2208, 0x2209,
|
||||
0x2190, 0x2191, 0x2192, 0x2193, 0x2194, 0x2195, 0x21d0, 0x21d1, 0x21d2, 0x21d3,
|
||||
0x2196, 0x2197, 0x2198, 0x2199, 0x454, 0xb7, 0x2505, 0x2026,
|
||||
0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, 0x398, 0x399, 0x39a, 0x39b,
|
||||
@@ -225,7 +227,18 @@ Layout TexParser::popCommand() {
|
||||
return popSumCommand();
|
||||
}
|
||||
}
|
||||
|
||||
if (strncmp(k_overlineCommand, m_text, strlen(k_overlineCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_overlineCommand)))) {
|
||||
m_text += strlen(k_overlineCommand);
|
||||
return popOverlineCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_intsetCommand, m_text, strlen(k_intsetCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_intsetCommand)))) {
|
||||
m_text += strlen(k_intsetCommand);
|
||||
return popIntsetCommand();
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < k_NumberOfSymbols; i++) {
|
||||
if (strncmp(k_SymbolsCommands[i], m_text, strlen(k_SymbolsCommands[i])) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_SymbolsCommands[i])))) {
|
||||
|
||||
@@ -35,7 +35,6 @@ private:
|
||||
Layout popSumCommand();
|
||||
Layout popSpaceCommand();
|
||||
|
||||
|
||||
//Symbols
|
||||
Layout popSymbolCommand(int SymbolIndex);
|
||||
|
||||
@@ -60,8 +59,6 @@ private:
|
||||
static constexpr char const * k_spaceCommand = "space";
|
||||
static constexpr char const * k_sqrtCommand = "sqrt";
|
||||
static constexpr char const * k_sumCommand = "sum";
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
KDCoordinate minimalHeightForOptimalDisplayGivenWidth(KDCoordinate width) const;
|
||||
void reload() { layoutSubviews(); }
|
||||
static constexpr const KDFont * Font() { return KDFont::SmallFont; }
|
||||
static constexpr const KDFont * Font() { return KDFont::ItalicSmallFont; }
|
||||
static constexpr KDColor TextColor() { return Palette::PrimaryText; }
|
||||
static constexpr KDColor BackgroundColor() { return Palette::SubMenuBackground; }
|
||||
private:
|
||||
|
||||
@@ -111,10 +111,12 @@ protected:
|
||||
m_cursorLocation = m_text.text();
|
||||
}
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void drawStringAt(KDContext * ctx, int line, int column, const char * text, int length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor) const;
|
||||
void drawStringAt(KDContext * ctx, int line, int column, const char * text, int length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor,bool isItalic = false) const;
|
||||
virtual void drawLine(KDContext * ctx, int line, const char * text, size_t length, int fromColumn, int toColumn, const char * selectionStart, const char * selectionEnd) const = 0;
|
||||
virtual void clearRect(KDContext * ctx, KDRect rect) const = 0;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
KDFont * usedFont;
|
||||
KDFont * ItalicFont;
|
||||
void setText(char * textBuffer, size_t textBufferSize);
|
||||
const char * text() const override { return m_text.text(); }
|
||||
const char * editedText() const override { return m_text.text(); }
|
||||
|
||||
@@ -513,21 +513,27 @@ void TextArea::ContentView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
}
|
||||
}
|
||||
|
||||
void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column, const char * text, int length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor) const {
|
||||
void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column, const char * text, int length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor, bool isItalic) const {
|
||||
if (length < 0) {
|
||||
return;
|
||||
}
|
||||
KDSize glyphSize = m_font->glyphSize();
|
||||
|
||||
}
|
||||
const KDFont * ItalicFont = (m_font == KDFont::LargeFont) ? KDFont::ItalicLargeFont : KDFont::ItalicSmallFont;
|
||||
const KDFont * usedFont = isItalic ? ItalicFont : m_font;
|
||||
|
||||
|
||||
KDSize glyphSize = usedFont->glyphSize();
|
||||
|
||||
bool drawSelection = selectionStart != nullptr && selectionEnd > text && selectionStart < text + length;
|
||||
|
||||
KDPoint nextPoint = ctx->drawString(
|
||||
text,
|
||||
KDPoint(column*glyphSize.width(), line*glyphSize.height()),
|
||||
m_font,
|
||||
textColor,
|
||||
backgroundColor,
|
||||
drawSelection ? (selectionStart >= text ? std::min<KDCoordinate>(length, selectionStart - text) : 0) : length
|
||||
);
|
||||
text,
|
||||
KDPoint(column*glyphSize.width(), line*glyphSize.height()),
|
||||
usedFont,
|
||||
textColor,
|
||||
backgroundColor,
|
||||
drawSelection ? (selectionStart >= text ? std::min<KDCoordinate>(length, selectionStart - text) : 0) : length
|
||||
);
|
||||
|
||||
if (!drawSelection) {
|
||||
return;
|
||||
}
|
||||
@@ -537,7 +543,7 @@ void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column,
|
||||
nextPoint = ctx->drawString(
|
||||
highlightedDrawStart,
|
||||
nextPoint,
|
||||
m_font,
|
||||
usedFont,
|
||||
textColor,
|
||||
backgroundHighlightColor,
|
||||
highlightedDrawLength);
|
||||
@@ -546,7 +552,7 @@ void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column,
|
||||
ctx->drawString(
|
||||
notHighlightedDrawStart,
|
||||
nextPoint,
|
||||
m_font,
|
||||
usedFont,
|
||||
textColor,
|
||||
backgroundColor,
|
||||
length - (notHighlightedDrawStart - text));
|
||||
@@ -557,7 +563,7 @@ KDSize TextArea::ContentView::minimalSizeForOptimalDisplay() const {
|
||||
return KDSize(
|
||||
/* We take into account the space required to draw a cursor at the end of
|
||||
* line by adding glyphSize.width() to the width. */
|
||||
span.width() + m_font->glyphSize().width(),
|
||||
span.width() + m_font->glyphSize().width() + 4,
|
||||
span.height()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,14 +66,18 @@ ifdef HAS_READER
|
||||
|
||||
kandinsky_src += $(addprefix kandinsky/fonts/, \
|
||||
LargeFontExtended.ttf \
|
||||
ItalicLargeFontExtended.ttf \
|
||||
SmallFontExtended.ttf \
|
||||
ItalicSmallFontExtended.ttf \
|
||||
LargeFontSimple.ttf \
|
||||
SmallFontSimple.ttf \
|
||||
)
|
||||
|
||||
default_kandinsky_src += $(addprefix kandinsky/fonts/, \
|
||||
LargeFontExtended.ttf \
|
||||
ItalicLargeFontExtended.ttf \
|
||||
SmallFontExtended.ttf \
|
||||
ItalicSmallFontExtended.ttf \
|
||||
)
|
||||
|
||||
simple_kandinsky_src += $(addprefix kandinsky/fonts/, \
|
||||
@@ -81,23 +85,28 @@ simple_kandinsky_src += $(addprefix kandinsky/fonts/, \
|
||||
SmallFontSimple.ttf \
|
||||
)
|
||||
|
||||
|
||||
$(eval $(call raster_font,SmallFont,SmallFontExtended,1,12,7,14))
|
||||
$(eval $(call raster_font,ItalicSmallFont,ItalicSmallFontExtended,1,12,7,14))
|
||||
$(eval $(call raster_font,LargeFont,LargeFontExtended,1,16,10,18))
|
||||
$(eval $(call raster_font,ItalicLargeFont,ItalicLargeFontExtended,1,16,10,18))
|
||||
|
||||
$(eval $(call raster_font,SmallFont,SmallFontSimple,0,12,7,14))
|
||||
$(eval $(call raster_font,LargeFont,LargeFontSimple,0,16,10,18))
|
||||
|
||||
else
|
||||
|
||||
kandinsky_src += $(addprefix kandinsky/fonts/, \
|
||||
LargeFont.ttf \
|
||||
ItalicLargeFont.ttf \
|
||||
SmallFont.ttf \
|
||||
ItalicSmallFont.ttf \
|
||||
)
|
||||
|
||||
default_kandinsky_src = $(kandinsky_src)
|
||||
simple_kandinsky_src = $(kandinsky_src)
|
||||
|
||||
$(eval $(call raster_font,SmallFont,SmallFontSimple,0,12,7,14))
|
||||
$(eval $(call raster_font,ItalicSmallFont,ItalicSmallFontSimple,0,12,7,14))
|
||||
$(eval $(call raster_font,LargeFont,LargeFontSimple,0,16,10,18))
|
||||
|
||||
$(eval $(call raster_font,ItalicLargeFont,ItalicLargeFontSimple,0,16,10,18))
|
||||
endif
|
||||
|
||||
BIN
kandinsky/fonts/ItalicLargeFont.ttf
Normal file
BIN
kandinsky/fonts/ItalicLargeFont.ttf
Normal file
Binary file not shown.
BIN
kandinsky/fonts/ItalicSmallFont.ttf
Normal file
BIN
kandinsky/fonts/ItalicSmallFont.ttf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -326,7 +326,7 @@ uint32_t ExtendedCodePoints[] = {
|
||||
0x3c7, // χ // GREEK SMALL LETTER KHI
|
||||
0x3c8, // ψ // GREEK SMALL LETTER PSI
|
||||
0x3c9, // ω // GREEK SMALL LETTER OMEGA
|
||||
0x454, // є // CYRILLIC SMALL LETTER UKRAINIAN LE
|
||||
0x454, // є // CYRILLIC SMALL LETTER UKRAINIAN LE - SMALL IN (in)
|
||||
0x1d07, // ᴇ // LATIN LETTER SMALL CAPITAL E
|
||||
0x2026, // … // HORIZONTAL ELLIPSIS
|
||||
0x212f, // ℯ // SCRIPT SMALL E
|
||||
@@ -346,16 +346,25 @@ uint32_t ExtendedCodePoints[] = {
|
||||
0x21d3, // ⇓ // DOUBLE BOTTOM ARROW (Downarrow)
|
||||
0x2200, // ∀ // FORALL
|
||||
0x2202, // ∂ // PARTIAL
|
||||
0x2203, // ∃ // EXIST
|
||||
0x2203, // ∃ // EXISTS (exists)
|
||||
0x2204, // ∄ // NOT EXISTS (nexists)
|
||||
0x2208, // ∈ // BIG IN (In)
|
||||
0x2209, // ∉ // BIG NOT IN (Notin)
|
||||
0x2211, // ∑ // N-ARY SUMMATION
|
||||
0x221a, // √ // SQUARE ROOT
|
||||
0x221e, // ∞ // INFINITY
|
||||
0x2229, // ∩ // SMALL INTERSECTION (cap)
|
||||
0x222a, // ∪ // SMALL UNION (cup)
|
||||
0x222b, // ∫ // INTEGRAL
|
||||
0x2248, // ≈ // ALMOST EQUAL TO
|
||||
0x2260, // ≠ // NOT EQUAL TO
|
||||
0x2261, // ≡ // IS CONGRUENT TO
|
||||
0x2264, // ≤ // LESS-THAN OR EQUAL TO
|
||||
0x2265, // ≥ // GREATER-THAN OR EQUAL TO
|
||||
0x2282, // ⊂ // IS INCLUDED (subset)
|
||||
0x2284, // ⊄ // IS NOT INCLUDED (nsubset)
|
||||
0x22c2, // ⋂ // BIG INTERSECTION (Cap)
|
||||
0x22c3, // ⋃ // BIG UNION (Cup)
|
||||
0x2505, // ┅ // BOX DRAWING EQU HEAVY DASH HORIZONTAL
|
||||
0x27e6, // ⟦ // MATHEMATICAL LEFT INT BRACKET SET
|
||||
0x27e7, // ⟧ // MATHEMATICAL RIGHT INT BRACKET SET
|
||||
|
||||
@@ -123,12 +123,15 @@ int main(int argc, char * argv[]) {
|
||||
}
|
||||
|
||||
int glyph_width = maxWidth-1;
|
||||
if (glyph_width == 9) { glyph_width = 10; } /* This was made to avoid a problem, the ratio of the width by the height was not */
|
||||
if (glyph_width == 8) { glyph_width = 7; } /* adequate and the fonts couldn't be compiled, this is useless with other fonts */
|
||||
if (packed_glyph_width != 0) {
|
||||
ENSURE(glyph_width == packed_glyph_width, "Expecting a packed glyph width of %d but got %d instead", packed_glyph_width, glyph_width);
|
||||
} else {
|
||||
printf("Computed packed_glyph_width = %d\n", glyph_width);
|
||||
}
|
||||
int glyph_height = maxAboveBaseline+maxBelowBaseline;
|
||||
if (glyph_height == 13) { glyph_height = 14;} /* Same problem */
|
||||
if (packed_glyph_height != 0) {
|
||||
ENSURE(glyph_height == packed_glyph_height, "Expecting a packed glyph height of %d but got %d instead", packed_glyph_height, glyph_height);
|
||||
} else {
|
||||
|
||||
@@ -28,10 +28,14 @@ private:
|
||||
static constexpr int k_bitsPerPixel = 4; // TODO: Should be generated by the rasterizer
|
||||
static constexpr int k_maxGlyphPixelCount = 180; //TODO: Should be generated by the rasterizer
|
||||
static const KDFont privateLargeFont;
|
||||
static const KDFont privateItalicLargeFont;
|
||||
static const KDFont privateSmallFont;
|
||||
static const KDFont privateItalicSmallFont;
|
||||
public:
|
||||
static constexpr const KDFont * LargeFont = &privateLargeFont;
|
||||
static constexpr const KDFont * ItalicLargeFont = &privateItalicLargeFont;
|
||||
static constexpr const KDFont * SmallFont = &privateSmallFont;
|
||||
static constexpr const KDFont * ItalicSmallFont = &privateItalicSmallFont;
|
||||
|
||||
static bool CanBeWrittenWithGlyphs(const char * text);
|
||||
|
||||
@@ -61,7 +65,7 @@ public:
|
||||
CodePoint m_codePoint;
|
||||
GlyphIndex m_glyphIndex;
|
||||
};
|
||||
static constexpr GlyphIndex IndexForReplacementCharacterCodePoint = 200;
|
||||
static constexpr GlyphIndex IndexForReplacementCharacterCodePoint = 209;
|
||||
GlyphIndex indexForCodePoint(CodePoint c) const;
|
||||
|
||||
void setGlyphGrayscalesForCodePoint(CodePoint codePoint, GlyphBuffer * glyphBuffer) const;
|
||||
|
||||
Reference in New Issue
Block a user