#define INITIAL 2
#define MEDIAL 3
+#define UNICODE_LAM 0x644
+
//
// 0: isolated form
// 1: ending form
static inline bool is_arabic_letter(uint32_t cp) { return ( cp >= ARABIC_LETTER_START && cp <= ARABIC_LETTER_END ); }
-static inline bool is_lam_alef(uint32_t cp, uint32_t next) { return cp == 0x644 &&
+static inline bool is_lam_alef(uint32_t cp, uint32_t next) { return cp == UNICODE_LAM &&
is_arabic_letter(next) &&
arabic_forms_b[next - ARABIC_LETTER_START][1][INITIAL] != 0; }
-static inline bool is_alef_prev_lam(uint32_t prev, uint32_t cp) { return prev == 0x644 &&
+static inline bool is_alef_prev_lam(uint32_t prev, uint32_t cp) { return prev == UNICODE_LAM &&
is_arabic_letter(cp) &&
arabic_forms_b[cp - ARABIC_LETTER_START][1][INITIAL] != 0; }
static inline bool is_linking_type(uint32_t cp) {
{
ui__->setupUi(this);
+ int width = 480;
+ int height = 320;
+ int font_size = 24;
+
std::ifstream ifs("arabic_test.txt");
assert( ifs.is_open() );
std::vector<uchar> arabic_string;
assert( !error && "unable to load font file" );
// set font size
- error = FT_Set_Pixel_Sizes(face, 0, 24);
+ error = FT_Set_Pixel_Sizes(face, 0, font_size);
assert( !error && "Error setting font size" );
// setup glyph
FT_Render_Mode render_flags = FT_RENDER_MODE_NORMAL;
- data__ = new uchar[1024 * 1024 * 4];
- memset(data__, 0, 1024 * 1024 * 4);
- int col = 1024 - 1;
- int line = 100;
- QImage img(data__, 1024, 1024, QImage::Format_RGB32);
+ data__ = new uchar[width * height * 4];
+ memset(data__, 0, width * height * 4);
+ int col = width - font_size;
+ int line = font_size;
+ QImage img(data__, width, height, QImage::Format_RGB32);
// render the arabic glyphs
for( size_t idx = 0; idx < arabic_cp.size(); ++idx )
{
uint ch = get_arabic_form(arabic_cp, idx);
if( ch == 0xA ) {
- line += 30;
- col = 1024 - 1;
+ line += font_size;
+ col = width - font_size;
continue;
}
FT_BBox box;
FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_TRUNCATE, &box);
- int temp_col = col - (slot->advance.x >> 6);//slot->bitmap.width;
+ int temp_col = col - (slot->advance.x >> 6);
for( int y = 0; y < slot->bitmap.rows; y++ )
{
for( int x = 0; x < slot->bitmap.width; x++ )
{
uchar co = slot->bitmap.buffer[x + y * slot->bitmap.pitch];
- if( co && x + temp_col < 1024 && x + temp_col >= 0 )
+ if( co && x + temp_col < width && x + temp_col >= 0 )
{
uint rgb = img.pixel(x + temp_col + slot->bitmap_left, y - slot->bitmap_top + line);
-
img.setPixel(x + temp_col + slot->bitmap_left, y - slot->bitmap_top + line, rgb | qRgb(co, co, co));
}
}
- for( int i = 0; i < 1024; ++i )
- //data__[i + 128 * 512 * 4 + 1] = 0xFF;
- img.setPixel(i, 128, 0xFF000000);
QPixmap pixmap = QPixmap::fromImage(img);
ui__->label->setPixmap(pixmap);