@@ -329,7 +329,7 @@ trim_borders(ProcessedBitmap *ans, size_t extra) {
329329 // Trim empty columns from the right side of the bitmap
330330 for (ssize_t x = ans -> width - 1 ; !column_has_text && x > -1 && extra > 0 ; x -- ) {
331331 for (size_t y = 0 ; y < ans -> rows && !column_has_text ; y ++ ) {
332- if (ans -> buf [x + y * ans -> stride ] > 200 ) column_has_text = true;
332+ if (ans -> buf [x + y * ans -> stride ] > 200 ) column_has_text = true; // TODO
333333 }
334334 if (!column_has_text ) { ans -> width -- ; extra -- ; }
335335 }
@@ -357,8 +357,17 @@ populate_processed_bitmap(FT_GlyphSlotRec *slot, FT_Bitmap *bitmap, ProcessedBit
357357static inline bool
358358render_bitmap (Face * self , int glyph_id , ProcessedBitmap * ans , unsigned int cell_width , unsigned int cell_height , unsigned int num_cells , bool bold , bool italic , bool rescale , FONTS_DATA_HANDLE fg ) {
359359 int flags = FT_LOAD_RENDER ;
360- if (OPT (use_subpixel_rendering ))
361- flags |= FT_LOAD_TARGET_LCD ;
360+ switch (OPT (subpixel_rendering )) {
361+ case SUBPIXEL_LCD :
362+ flags |= FT_LOAD_TARGET_LCD ;
363+ break ;
364+ case SUBPIXEL_LCD_V :
365+ flags |= FT_LOAD_TARGET_LCD_V ;
366+ break ;
367+ case SUBPIXEL_NONE :
368+ default :
369+ break ;
370+ }
362371 if (!load_glyph (self , glyph_id , flags )) return false;
363372 unsigned int max_width = cell_width * num_cells ;
364373
@@ -383,6 +392,9 @@ render_bitmap(Face *self, int glyph_id, ProcessedBitmap *ans, unsigned int cell_
383392 } else if (self -> face -> glyph -> bitmap .pixel_mode == FT_PIXEL_MODE_LCD ) {
384393 populate_processed_bitmap (self -> face -> glyph , & self -> face -> glyph -> bitmap , ans , false);
385394 ans -> width /= 3 ;
395+ } else if (self -> face -> glyph -> bitmap .pixel_mode == FT_PIXEL_MODE_LCD_V ) {
396+ populate_processed_bitmap (self -> face -> glyph , & self -> face -> glyph -> bitmap , ans , false);
397+ // TODO: tune ans->rows, as it's 3 times biger than the actual height
386398 } else {
387399 populate_processed_bitmap (self -> face -> glyph , & self -> face -> glyph -> bitmap , ans , false);
388400 }
@@ -547,6 +559,9 @@ place_bitmap_in_canvas(pixel *cell, ProcessedBitmap *bm, size_t cell_width, size
547559 copy_color_bitmap (bm -> buf , cell , & src , & dest , bm -> stride , cell_width );
548560 } else if (bm -> pixel_mode == FT_PIXEL_MODE_LCD ) {
549561 copy_lcd_bitmap (bm -> buf , cell , & src , & dest , bm -> stride , cell_width , bgr );
562+ } else if (bm -> pixel_mode == FT_PIXEL_MODE_LCD_V ) {
563+ // copy_lcd_v_bitmap(bm->buf, cell, &src, &dest, bm->stride, cell_width, bgr);
564+ // TODO: implement it
550565 } else render_alpha_mask (bm -> buf , cell , & src , & dest , bm -> stride , cell_width );
551566}
552567
@@ -570,7 +585,7 @@ render_glyphs_in_cells(PyObject *f, bool bold, bool italic, hb_glyph_info_t *inf
570585 } else {
571586 if (!render_bitmap (self , info [i ].codepoint , & bm , cell_width , cell_height , num_cells , bold , italic , true, fg )) return false;
572587 }
573- * was_subpixel = (bm .pixel_mode == FT_PIXEL_MODE_LCD );
588+ * was_subpixel = (bm .pixel_mode == FT_PIXEL_MODE_LCD || bm . pixel_mode = FT_PIXEL_MODE_LCD_V );
574589 x_offset = x + (float )positions [i ].x_offset / 64.0f ;
575590 y = (float )positions [i ].y_offset / 64.0f ;
576591 if ((* was_colored || self -> face -> glyph -> metrics .width > 0 ) && bm .width > 0 ) {
@@ -623,10 +638,18 @@ render_simple_text_impl(PyObject *s, const char *text, unsigned int baseline) {
623638 int error = FT_Load_Glyph (self -> face , glyph_index , FT_LOAD_DEFAULT );
624639 if (error ) continue ;
625640 int flags = 0 ;
626- if (OPT (use_subpixel_rendering ))
627- flags |= FT_RENDER_MODE_LCD ;
628- else
629- flags |= FT_RENDER_MODE_NORMAL ;
641+ switch (OPT (subpixel_rendering )) {
642+ case SUBPIXEL_LCD :
643+ flags |= FT_RENDER_MODE_LCD ;
644+ break ;
645+ case SUBPIXEL_LCD_V :
646+ flags |= FT_RENDER_MODE_LCD_V ;
647+ break ;
648+ case SUBPIXEL_NONE :
649+ default :
650+ flags |= FT_RENDER_MODE_NORMAL ;
651+ break ;
652+ }
630653 error = FT_Render_Glyph (self -> face -> glyph , flags );
631654 if (error ) continue ;
632655 FT_Bitmap * bitmap = & self -> face -> glyph -> bitmap ;
0 commit comments