diff --git a/include/gdi.h b/include/gdi.h index f9417507..b7411dce 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -12375,27 +12375,34 @@ MG_EXPORT int GUIAPI UChars2AChars(LOGFONT* logfont, const Uchar32* ucs, */ #define GRF_ALIGN_CENTER 0x00004000 /** - * Text is justified according to the method specified by GRF_TEXT_JUSTIFY_XXX, - * in order to exactly fill the line box. + * All lines will be justified according to the method specified by + * GRF_TEXT_JUSTIFY_XXX, in order to exactly fill the line box. + * + * If you specify only a valid justification method (not GRF_TEXT_JUSTIFY_NONE) + * without GRF_ALIGN_JUSTIFY, the last line will not be justified. */ #define GRF_ALIGN_JUSTIFY 0x00005000 #define GRF_TEXT_JUSTIFY_MASK 0x00000F00 +/** + * Do not justify. + */ +#define GRF_TEXT_JUSTIFY_NONE 0x00000000 /** * Justification adjusts primarily the spacing at word separators * and between CJK typographic letter units along with secondarily * between Southeast Asian typographic letter units. */ -#define GRF_TEXT_JUSTIFY_AUTO 0x00000000 +#define GRF_TEXT_JUSTIFY_AUTO 0x00000100 /** * Justification adjusts spacing at word separators only. */ -#define GRF_TEXT_JUSTIFY_INTER_WORD 0x00000100 +#define GRF_TEXT_JUSTIFY_INTER_WORD 0x00000200 /** * Justification adjusts spacing between each pair of adjacent * typographic character units. */ -#define GRF_TEXT_JUSTIFY_INTER_CHAR 0x00000200 +#define GRF_TEXT_JUSTIFY_INTER_CHAR 0x00000300 #define GRF_HANGING_PUNC_MASK 0x000000F0 /** diff --git a/src/newgdi/layout.c b/src/newgdi/layout.c index 0de25992..46c469ef 100644 --- a/src/newgdi/layout.c +++ b/src/newgdi/layout.c @@ -1677,15 +1677,20 @@ static void layout_line_postprocess (LAYOUTLINE *line, adjust_line_letter_spacing (line, state); /* - * Distribute extra space between words if justifying and line was wrapped + * Distribute extra space between words if justifying */ - if ((line->layout->rf & GRF_ALIGN_MASK) == GRF_ALIGN_JUSTIFY && - (wrapped || ellipsized)) { + if (((line->layout->rf & GRF_ALIGN_MASK) == GRF_ALIGN_JUSTIFY && + (line->layout->rf & GRF_TEXT_JUSTIFY_MASK) != GRF_TEXT_JUSTIFY_NONE) || + ((line->layout->rf & GRF_TEXT_JUSTIFY_MASK) != GRF_TEXT_JUSTIFY_NONE && + (wrapped || ellipsized))) { /* if we ellipsized, we don't have remaining_width set */ if (state->remaining_width < 0) state->remaining_width = state->line_width - layout_line_get_width (line); + // TODO: + // implement GRF_TEXT_JUSTIFY_AUTO, GRF_TEXT_JUSTIFY_INTER_WORD, + // and GRF_TEXT_JUSTIFY_INTER_CHAR justify_words (line, state); }