void font_draw_glyphs(struct vg_font *font, VGint glyphCount, const VGuint *glyphIndices, const VGfloat *adjustments_x, const VGfloat *adjustments_y, VGbitfield paintModes, VGboolean allowAutoHinting) { struct vg_context *ctx = vg_current_context(); VGint i; for (i = 0; i < glyphCount; ++i) { if (!get_glyph(font, glyphIndices[i])) { vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); return; } } for (i = 0; i < glyphCount; ++i) { struct vg_glyph *glyph; VGfloat adj_x, adj_y; glyph = get_glyph(font, glyphIndices[i]); vg_render_glyph(ctx, glyph, paintModes, allowAutoHinting); adj_x = (adjustments_x) ? adjustments_x[i] : 0.0f; adj_y = (adjustments_y) ? adjustments_y[i] : 0.0f; vg_advance_glyph(ctx, glyph, adj_x, adj_y, (i == glyphCount - 1)); } }
static cairo_test_status_t draw (cairo_t *cr, int width, int height) { const cairo_test_context_t *ctx = cairo_test_get_context (cr); cairo_glyph_t *glyphs = xmalloc (NUM_GLYPHS * sizeof (cairo_glyph_t)); cairo_scaled_font_t *scaled_font; const char *characters[] = { /* try to exercise different widths of index */ "m", /* Latin letter m, index=0x50 */ "μ", /* Greek letter mu, index=0x349 */ NULL, }, **utf8; int i, j; cairo_status_t status; /* Paint white background. */ cairo_set_source_rgb (cr, 1, 1, 1); cairo_paint (cr); cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (cr, TEXT_SIZE); scaled_font = cairo_get_scaled_font (cr); for (utf8 = characters; *utf8 != NULL; utf8++) { status = get_glyph (ctx, scaled_font, *utf8, &glyphs[0]); if (status) goto BAIL; if (glyphs[0].index) { glyphs[0].x = 1.0; glyphs[0].y = height - 1; for (i=1; i < NUM_GLYPHS; i++) glyphs[i] = glyphs[0]; cairo_show_glyphs (cr, glyphs, NUM_GLYPHS); } } /* we can pack ~21k 1-byte glyphs into a single XRenderCompositeGlyphs8 */ status = get_glyph (ctx, scaled_font, "m", &glyphs[0]); if (status) goto BAIL; for (i=1; i < 21500; i++) glyphs[i] = glyphs[0]; /* so check expanding the current 1-byte request for 2-byte glyphs */ status = get_glyph (ctx, scaled_font, "μ", &glyphs[i]); if (status) goto BAIL; for (j=i+1; j < NUM_GLYPHS; j++) glyphs[j] = glyphs[i]; cairo_show_glyphs (cr, glyphs, NUM_GLYPHS); BAIL: free(glyphs); return status; }
/** * @brief Converts raw cell patterns from io_line to glyphs in io_parsed * @param void * @return bool - true if all raw cells were valid, false otherwise */ bool io_convert_line(void) { int line_index = 0; int parse_index = 0; glyph_t* curr_glyph = NULL; // Iterate through io_line, find matching glyph for each cell pattern as long // as it isn't END_OF_TEXT, and add to io_parsed for (line_index = 0, parse_index = 0; line_index - 2 < MAX_BUF_SIZE; line_index++, parse_index++) { if (io_line[line_index] == END_OF_TEXT) { break; } curr_glyph = get_glyph(lang_script, io_line, &line_index); if (curr_glyph == NULL) { return false; } else { //log_msg("[IO] Parsed glyph[%d]: %s pattern:%x\n\r", parse_index, curr_glyph->sound, curr_glyph->pattern); log_msg("[IO] Parsed glyph[%d]: %s(0x%x)\n\r", parse_index, curr_glyph->sound,curr_glyph->pattern); io_parsed[parse_index] = curr_glyph; } } // If control returns from loop then matching glyphs were found for all // raw cells, add a NULL terminator and return true io_parsed[line_index] = NULL; io_init(); log_msg("[IO] line index[%d]: \n\r", line_index); return true; }
t_stat parse_sym_m (char *cptr, t_value *val) { char *start; uint32 n,a; char gbuf[CBUFSIZE]; start = cptr; cptr = get_glyph(cptr, gbuf, 0); if (*start) *start = 'x'; for (n = 0; opcode[n] != NULL && strcmp(opcode[n], gbuf) != 0; n++) ; if (opcode[n] == NULL) return SCPE_ARG; /* invalid mnemonic? */ if (!(*cptr) && n > OP_UNDOCUMENTED && n <= OP_STOP) { *val = n << I_V_OP; return SCPE_OK; } while (isspace (*cptr)) cptr++; /* absorb spaces */ if (*cptr < '0' || *cptr > '9') return SCPE_ARG; /* address expected */ a = 0; while (*cptr >= '0' && *cptr <= '9') { a = (a * 10) + (*cptr - '0'); cptr++; } if (a >= MEMSIZE) return SCPE_ARG; /* invalid address? */ if (*cptr) return SCPE_ARG; /* junk at end? */ *val = (n << I_V_OP) + a; return SCPE_OK; }
t_stat cpu_set_model (UNIT *uptr, int32 val, char *cptr, void *desc) { #if defined(HAVE_LIBSDL) char gbuf[CBUFSIZE]; if ((cptr == NULL) || (!*cptr)) return SCPE_ARG; cptr = get_glyph (cptr, gbuf, 0); if (MATCH_CMD(gbuf, "MICROVAX") == 0) { sys_model = 0; vc_dev.flags = vc_dev.flags | DEV_DIS; /* disable QVSS */ lk_dev.flags = lk_dev.flags | DEV_DIS; /* disable keyboard */ vs_dev.flags = vs_dev.flags | DEV_DIS; /* disable mouse */ strcpy (sim_name, "MicroVAX I (KA610)"); reset_all (0); /* reset everything */ } else if (MATCH_CMD(gbuf, "VAXSTATION") == 0) { sys_model = 1; vc_dev.flags = vc_dev.flags & ~DEV_DIS; /* enable QVSS */ lk_dev.flags = lk_dev.flags & ~DEV_DIS; /* enable keyboard */ vs_dev.flags = vs_dev.flags & ~DEV_DIS; /* enable mouse */ strcpy (sim_name, "VAXStation I (KA610)"); reset_all (0); /* reset everything */ } else return SCPE_ARG; return SCPE_OK; #else return SCPE_NOFNC; #endif }
void FontProvider_Sprite::draw_text(Canvas &canvas, float xpos, float ypos, float scale_x, float scale_y, const std::string &text, const Colorf &color) { float f_spacelen = spacelen; float ascent = font_metrics.get_ascent() * scale_x; // Scan the string UTF8_Reader reader(text.data(), text.length()); while(!reader.is_end()) { unsigned int glyph = reader.get_char(); reader.next(); Font_Sprite_Glyph *gptr = get_glyph(glyph); if (gptr) { spr_glyphs.set_frame(gptr->sprite_index); Size frame_size = spr_glyphs.get_frame_size(gptr->sprite_index); float dest_width = scale_x * frame_size.width; float dest_height = scale_y * frame_size.height; spr_glyphs.set_color(color); spr_glyphs.draw(canvas, Rectf(xpos, ypos - ascent, Sizef(dest_width, dest_height))); xpos += dest_width; } else { xpos += f_spacelen; } } }
CL_Size CL_GlyphCache::get_text_size(CL_FontEngine *font_engine, CL_GraphicContext &gc, const CL_StringRef &text) { int width = 0; CL_UTF8_Reader reader(text); while(!reader.is_end()) { unsigned int glyph = reader.get_char(); reader.next(); CL_Font_TextureGlyph *gptr = get_glyph(font_engine, gc, glyph); if (gptr == NULL) continue; width += gptr->increment.x; } int height; if (width == 0) { height = 0; } else { height = font_metrics.get_ascent() + font_metrics.get_descent(); } return (CL_Size(width, height)); }
void display_ch (int y, int x, char ch, unsigned short fg, unsigned short bg) { char *fadr; unsigned short *fb, c; int i, j, k; // Find glyph address for ch fadr = get_glyph (ch); // for each bit in glyph, set pixel to either fg or bg for (i=0; i<char_height; i++) { fb = (unsigned short *)(fbadr + ( ((y * char_height) + i + window_top) * screen_width + (x * char_width + window_left)) * pixel_bytes ); for (j=0; j<char_width; j++) { k = (fadr[j>>3] >> (7-(j&7))) & 1; if (k==1) c = fg; else c = bg; *fb = c; fb++; } fadr += font_bytes; } }
t_stat cpu_set_model (UNIT *uptr, int32 val, char *cptr, void *desc) { char gbuf[CBUFSIZE]; if ((cptr == NULL) || (!*cptr)) return SCPE_ARG; cptr = get_glyph (cptr, gbuf, 0); if (MATCH_CMD(gbuf, "MICROVAX") == 0) { sys_model = 0; #if defined(USE_SIM_VIDEO) && defined(HAVE_LIBSDL) vc_dev.flags = vc_dev.flags | DEV_DIS; /* disable QVSS */ lk_dev.flags = lk_dev.flags | DEV_DIS; /* disable keyboard */ vs_dev.flags = vs_dev.flags | DEV_DIS; /* disable mouse */ #endif strcpy (sim_name, "MicroVAX I (KA610)"); reset_all (0); /* reset everything */ } else if (MATCH_CMD(gbuf, "VAXSTATION") == 0) { #if defined(USE_SIM_VIDEO) && defined(HAVE_LIBSDL) sys_model = 1; vc_dev.flags = vc_dev.flags & ~DEV_DIS; /* enable QVSS */ lk_dev.flags = lk_dev.flags & ~DEV_DIS; /* enable keyboard */ vs_dev.flags = vs_dev.flags & ~DEV_DIS; /* enable mouse */ strcpy (sim_name, "VAXStation I (KA610)"); reset_all (0); /* reset everything */ #else return sim_messagef(SCPE_ARG, "Simulator built without Graphic Device Support"); #endif } else return SCPE_ARG; return SCPE_OK; }
t_stat vax780_fload (int32 flag, char *cptr) { char gbuf[CBUFSIZE]; uint16 file_name[3], blkbuf[BLK_SIZE]; t_stat r; uint32 i, j, start, size, origin; if ((fl_unit.flags & UNIT_ATT) == 0) /* floppy attached? */ return SCPE_UNATT; if (*cptr == 0) return SCPE_2FARG; cptr = get_glyph (cptr, gbuf, 0); /* get file name */ if (!rtfile_parse (gbuf, file_name)) /* legal file name? */ return SCPE_ARG; if ((size = rtfile_lookup (file_name, &start)) == 0) /* file on floppy? */ return SCPE_ARG; if (*cptr) { /* origin? */ origin = (uint32) get_uint (cptr, 16, MEMSIZE, &r); if ((r != SCPE_OK) || (origin & 1)) /* must be even */ return SCPE_ARG; } else origin = 512; /* no, use default */ for (i = 0; i < size; i++) { /* loop thru blocks */ if (!rtfile_read (start + i, 1, blkbuf)) /* read block */ return SCPE_FMT; for (j = 0; j < BLK_SIZE; j++) { /* loop thru words */ if (ADDR_IS_MEM (origin)) WriteW (origin, blkbuf[j]); else return SCPE_NXM; origin = origin + 2; } } return SCPE_OK; }
GlyphMetrics GlyphCache::get_metrics(FontEngine *font_engine, const CanvasPtr &canvas, unsigned int glyph) { Font_TextureGlyph *gptr = get_glyph(canvas, font_engine, glyph); if (gptr) { return gptr->metrics; } return GlyphMetrics(); }
t_stat lp_load_cct (UNIT *uptr, int32 val, CONST char *cptr, void *desc) { uint32 col, rpt, ptr, mask; uint8 cctbuf[CCT_LNT]; t_stat r; char cbuf[CBUFSIZE], gbuf[CBUFSIZE]; FILE *cfile; if ((cptr == NULL) || (*cptr == 0)) return SCPE_ARG; if ((cfile = fopen (cptr, "r")) == NULL) return SCPE_OPENERR; ptr = 0; for ( ; (cptr = fgets (cbuf, CBUFSIZE, cfile)) != NULL; ) { mask = 0; if (*cptr == '(') { /* repeat count? */ cptr = get_glyph (cptr + 1, gbuf, ')'); /* get 1st field */ rpt = get_uint (gbuf, 10, CCT_LNT, &r); /* repeat count */ if (r != SCPE_OK) return SCPE_FMT; } else rpt = 1; while (*cptr != 0) { /* get col no's */ cptr = get_glyph (cptr, gbuf, ','); /* get next field */ col = get_uint (gbuf, 10, FMT_MCH4, &r); /* column number */ if (r != SCPE_OK) return SCPE_FMT; mask = mask | (1 << col); /* set bit */ } for ( ; rpt > 0; rpt--) { /* store vals */ if (ptr >= CCT_LNT) return SCPE_FMT; cctbuf[ptr++] = mask; } } if (ptr == 0) return SCPE_FMT; lp_cctl = ptr; lp_cctp = 0; for (rpt = 0; rpt < lp_cctl; rpt++) lp_cct[rpt] = cctbuf[rpt]; fclose (cfile); return SCPE_OK; }
void font_impl::draw(const string & str) const { glPushAttrib(GL_ALL_ATTRIB_BITS); CHECK_GL_ERRORS(); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); CHECK_GL_ERRORS(); glPolygonMode(GL_FRONT, GL_FILL); CHECK_GL_ERRORS(); glEnable(GL_BLEND); CHECK_GL_ERRORS(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); CHECK_GL_ERRORS(); glEnable(GL_TEXTURE_2D); CHECK_GL_ERRORS(); const gsgl::index_t len = str.size(); for (gsgl::index_t i = 0; i < len; ++i) { const wchar_t ch = str[i]; texture *t = get_glyph(ch); if (t) { t->bind(); float pct_y = glyph_pct_y[ch]; float pct_x = glyph_pct_x[ch]; glBegin(GL_TRIANGLE_STRIP); // upper left glTexCoord2f(0.0f, pct_y); glVertex2f(0.0f, static_cast<GLfloat>(font_height)); // lower left glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); // upper right glTexCoord2f(pct_x, pct_y); glVertex2f(glyph_widths[ch], static_cast<GLfloat>(font_height)); // lower right glTexCoord2f(pct_x, 0.0f); glVertex2f(glyph_widths[ch], 0.0f); glEnd(); CHECK_GL_ERRORS(); //display::draw_rectangle(0, 0, glyph_widths[ch], static_cast<GLfloat>(font_height), 0, 0, pct_x, pct_y); } glMatrixMode(GL_MODELVIEW); CHECK_GL_ERRORS(); glTranslatef(glyph_widths[ch], 0.0f, 0.0f); CHECK_GL_ERRORS(); } glPopClientAttrib(); CHECK_GL_ERRORS(); glPopAttrib(); CHECK_GL_ERRORS(); } // font_impl::draw()
/* * Returns size occupied by the last glyph. Here we take advance_x into account. */ static unsigned int last_glyph_width(const GP_TextStyle *style, int c) { unsigned int size, advance; const GP_GlyphBitmap *glyph = get_glyph(style, c); advance = multiply_width(style, glyph->advance_x); size = multiply_width(style, glyph->width + glyph->bearing_x); return (size > advance) ? size : advance; }
t_stat lp_load (FILE *fileref, CONST char *cptr, CONST char *fnam) { int32 col, ptr, mask, vfubuf[VFU_LNT]; uint32 rpt; t_stat r; char cbuf[CBUFSIZE], gbuf[CBUFSIZE]; if (*cptr != 0) return SCPE_ARG; ptr = 0; for ( ; (cptr = fgets (cbuf, CBUFSIZE, fileref)) != NULL; ) { /* until eof */ mask = 0; if (*cptr == '(') { /* repeat count? */ cptr = get_glyph (cptr + 1, gbuf, ')'); /* get 1st field */ rpt = get_uint (gbuf, 10, VFU_LNT, &r); /* repeat count */ if (r != SCPE_OK) return SCPE_FMT; } else rpt = 1; while (*cptr != 0) { /* get col no's */ cptr = get_glyph (cptr, gbuf, ','); /* get next field */ col = get_uint (gbuf, 10, 7, &r); /* column number */ if (r != SCPE_OK) return SCPE_FMT; mask = mask | (1 << col); /* set bit */ } for ( ; rpt > 0; rpt--) { /* store vals */ if (ptr >= VFU_LNT) return SCPE_FMT; vfubuf[ptr++] = mask; } } if (ptr == 0) return SCPE_FMT; lpt_vful = ptr; lpt_vfup = 0; for (rpt = 0; rpt < lpt_vful; rpt++) lpt_vfut[rpt] = vfubuf[rpt]; return SCPE_OK; }
void Worldmap::draw(int posx, int posy) { int origx = posx, origy = posy; int xdim, ydim; get_screen_dims(xdim, ydim); Window w_worldmap(0, 0, xdim, ydim); int winx = w_worldmap.sizex(), winy = w_worldmap.sizey(); bool done = false; while (!done) { for (int x = 0; x < winx; x++) { for (int y = 0; y < winy; y++) { int terx = posx + x - (winx / 2), tery = posy + y - (winy / 2); glyph sym = get_glyph(terx, tery); if ((terx == posx && tery == posy) || (terx == origx && tery == origy) ) { sym = sym.invert(); } else if (terx >= 0 && tery >= 0 && terx < WORLDMAP_SIZE && tery < WORLDMAP_SIZE && !tiles[terx][tery].monsters.empty()) { sym = sym.hilite(c_red); } w_worldmap.putglyph(x, y, sym); } } w_worldmap.refresh(); long ch = input(); switch (ch) { case 'j': case '2': case KEY_DOWN: posy++; break; case 'k': case '8': case KEY_UP: posy--; break; case 'h': case '4': case KEY_LEFT: posx--; break; case 'l': case '6': case KEY_RIGHT: posx++; break; case 'y': case '7': posx--; posy--; break; case 'u': case '9': posx++; posy--; break; case 'b': case '1': posx--; posy++; break; case 'n': case '3': posx++; posy++; break; case 'q': case 'Q': done = true; break; } } }
void Worldmap::draw_minimap(cuss::element *drawing, int cornerx, int cornery) { for (int x = 0; x < drawing->sizex; x++) { for (int y = 0; y < drawing->sizey; y++) { int terx = cornerx + x, tery = cornery + y; glyph sym = get_glyph(terx, tery); if (x == drawing->sizex / 2 && y == drawing->sizey / 2) { sym = sym.invert(); } drawing->set_data(sym, x, y); } } }
int CL_GlyphCache::get_character_index(CL_FontEngine *font_engine, CL_GraphicContext &gc, const CL_String &text, const CL_Point &point) { int dest_x = 0; int dest_y = 0; int character_counter = 0; CL_FontMetrics fm = get_font_metrics(); int font_height = fm.get_height(); int font_ascent = fm.get_ascent(); int font_external_leading = fm.get_external_leading(); std::vector<CL_String> lines = CL_StringHelp::split_text(text, "\n", false); for (std::vector<CL_String>::size_type i=0; i<lines.size(); i++) { int xpos = dest_x; int ypos = dest_y; CL_String &textline = lines[i]; CL_String::size_type string_length = textline.length(); // Scan the string CL_UTF8_Reader reader(textline); while(!reader.is_end()) { unsigned int glyph = reader.get_char(); CL_String::size_type glyph_pos = reader.get_position(); reader.next(); CL_Font_TextureGlyph *gptr = get_glyph(font_engine, gc, glyph); if (gptr == NULL) continue; CL_Rect position(xpos, ypos - font_ascent, CL_Size(gptr->increment.x, gptr->increment.y + font_height + font_external_leading)); if (position.contains(point)) { return glyph_pos + character_counter; } xpos += gptr->increment.x; ypos += gptr->increment.y; } dest_y += font_height + font_external_leading; character_counter += string_length + 1; // (Including the '\n') } return -1; // Not found }
int FontProvider_Sprite::get_character_index(GraphicContext &gc, const std::string &text, const Point &point) { int dest_x = 0; int dest_y = 0; int character_counter = 0; FontMetrics fm = get_font_metrics(); int font_height = fm.get_height(); int font_external_leading = fm.get_external_leading(); std::vector<std::string> lines = StringHelp::split_text(text, "\n", false); for (std::vector<std::string>::size_type i=0; i<lines.size(); i++) { int xpos = dest_x; int ypos = dest_y; std::string &textline = lines[i]; std::string::size_type string_length = textline.length(); // Scan the string for (std::string::size_type p = 0; p < string_length; p++) { Font_Sprite_Glyph *gptr = get_glyph(textline[p]); int glyph_width; if (gptr) { glyph_width = spr_glyphs.get_frame_size(gptr->sprite_index).width; } else { glyph_width = spacelen; } Rect position(xpos, ypos - font_height, Size(glyph_width, font_height + font_external_leading)); if (position.contains(point)) return ((int) p) + character_counter; xpos += glyph_width; } dest_y += font_height + font_external_leading; character_counter += string_length + 1; // (Including the '\n') } return -1; // Not found }
t_stat dtc_set_log (UNIT *uptr, int32 val, CONST char *cptr, void *desc) { t_stat r; char gbuf[CBUFSIZE]; int32 ln; if (cptr == NULL) return SCPE_ARG; cptr = get_glyph (cptr, gbuf, '='); if ((cptr == NULL) || (*cptr == 0) || (gbuf[0] == 0)) return SCPE_ARG; ln = (int32) get_uint (gbuf, 10, dtc_desc.lines, &r); if ((r != SCPE_OK) || (ln >= dtc_desc.lines)) return SCPE_ARG; return tmxr_set_log (NULL, ln, cptr, desc); }
font_face_set::dimension_t font_face_set::character_dimensions(const unsigned c) { std::map<unsigned, dimension_t>::const_iterator itr; itr = dimension_cache_.find(c); if (itr != dimension_cache_.end()) { return itr->second; } FT_Matrix matrix; FT_Vector pen; FT_Error error; pen.x = 0; pen.y = 0; FT_BBox glyph_bbox; FT_Glyph image; glyph_ptr glyph = get_glyph(c); FT_Face face = glyph->get_face()->get_face(); matrix.xx = (FT_Fixed)( 1 * 0x10000L ); matrix.xy = (FT_Fixed)( 0 * 0x10000L ); matrix.yx = (FT_Fixed)( 0 * 0x10000L ); matrix.yy = (FT_Fixed)( 1 * 0x10000L ); FT_Set_Transform(face, &matrix, &pen); error = FT_Load_Glyph (face, glyph->get_index(), FT_LOAD_NO_HINTING); if ( error ) return dimension_t(0, 0, 0); error = FT_Get_Glyph(face->glyph, &image); if ( error ) return dimension_t(0, 0, 0); FT_Glyph_Get_CBox(image, ft_glyph_bbox_pixels, &glyph_bbox); FT_Done_Glyph(image); unsigned tempx = face->glyph->advance.x >> 6; //std::clog << "glyph: " << glyph_index << " x: " << tempx << " y: " << tempy << std::endl; dimension_t dim(tempx, glyph_bbox.yMax, glyph_bbox.yMin); //dimension_cache_[c] = dim; would need an default constructor for dimension_t dimension_cache_.insert(std::pair<unsigned, dimension_t>(c, dim)); return dim; }
void font_draw_glyph(struct vg_font *font, VGuint glyphIndex, VGbitfield paintModes, VGboolean allowAutoHinting) { struct vg_context *ctx = vg_current_context(); struct vg_glyph *glyph; glyph = get_glyph(font, glyphIndex); if (!glyph) { vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); return; } vg_render_glyph(ctx, glyph, paintModes, allowAutoHinting); vg_advance_glyph(ctx, glyph, 0.0f, 0.0f, VG_TRUE); }
t_stat vt_set_vspace(UNIT *uptr, int32 val, char *cptr, void *desc) { char gbuf[CBUFSIZE]; if (vt11_init) return SCPE_ALATT; /* should be "changes locked out" */ if (cptr == NULL) return SCPE_ARG; get_glyph(cptr, gbuf, 0); if (strcmp(gbuf, "TALL") == 0) vt11_csp_h = 26; else if (strcmp(gbuf, "NORMAL") == 0) vt11_csp_h = 24; else return SCPE_ARG; return SCPE_OK; }
char_info font_face_set::character_dimensions(const unsigned c) { //Check if char is already in cache std::map<unsigned, char_info>::const_iterator itr; itr = dimension_cache_.find(c); if (itr != dimension_cache_.end()) { return itr->second; } FT_Matrix matrix; FT_Vector pen; FT_Error error; pen.x = 0; pen.y = 0; FT_BBox glyph_bbox; FT_Glyph image; glyph_ptr glyph = get_glyph(c); FT_Face face = glyph->get_face()->get_face(); matrix.xx = (FT_Fixed)( 1 * 0x10000L ); matrix.xy = (FT_Fixed)( 0 * 0x10000L ); matrix.yx = (FT_Fixed)( 0 * 0x10000L ); matrix.yy = (FT_Fixed)( 1 * 0x10000L ); FT_Set_Transform(face, &matrix, &pen); error = FT_Load_Glyph (face, glyph->get_index(), FT_LOAD_NO_HINTING); if ( error ) return char_info(); error = FT_Get_Glyph(face->glyph, &image); if ( error ) return char_info(); FT_Glyph_Get_CBox(image, ft_glyph_bbox_pixels, &glyph_bbox); FT_Done_Glyph(image); unsigned tempx = face->glyph->advance.x >> 6; char_info dim(c, tempx, glyph_bbox.yMax, glyph_bbox.yMin, face->size->metrics.height/64.0 /* >> 6 */); dimension_cache_.insert(std::pair<unsigned, char_info>(c, dim)); return dim; }
t_stat vt_set_crt(UNIT *uptr, int32 val, char *cptr, void *desc) { char gbuf[CBUFSIZE]; if (vt11_init) return SCPE_ALATT; /* should be "changes locked out" */ if (cptr == NULL) return SCPE_ARG; get_glyph(cptr, gbuf, 0); if (strcmp(gbuf, "VR14") == 0) vt11_display = DIS_VR14; else if (strcmp(gbuf, "VR17") == 0) vt11_display = DIS_VR17; else if (strcmp(gbuf, "VR48") == 0) vt11_display = DIS_VR48; else return SCPE_ARG; vt_dib.lnt = (VS60) ? IOLN_VS60 : IOLN_VT11; return SCPE_OK; }
t_stat sim_tape_attach (UNIT *uptr, char *cptr) { uint32 objc; char gbuf[CBUFSIZE]; t_stat r; if (sim_switches & SWMASK ('F')) { /* format spec? */ cptr = get_glyph (cptr, gbuf, 0); /* get spec */ if (*cptr == 0) /* must be more */ return SCPE_2FARG; if (sim_tape_set_fmt (uptr, 0, gbuf, NULL) != SCPE_OK) return SCPE_ARG; } r = (uptr, cptr); /* attach unit */ if (r != SCPE_OK) /* error? */ return r; switch (MT_GET_FMT (uptr)) { /* case on format */ case MTUF_F_TPC: /* TPC */ objc = sim_tape_tpc_map (uptr, NULL); /* get # objects */ if (objc == 0) { /* tape empty? */ sim_tape_detach (uptr); return SCPE_FMT; /* yes, complain */ } uptr->filebuf = calloc (objc + 1, sizeof (t_addr)); if (uptr->filebuf == NULL) { /* map allocated? */ sim_tape_detach (uptr); return SCPE_MEM; /* no, complain */ } uptr->hwmark = objc + 1; /* save map size */ sim_tape_tpc_map (uptr, (t_addr *) uptr->filebuf); /* fill map */ break; default: break; } sim_tape_rewind (uptr); return SCPE_OK; }
t_stat sim_load (FILE *fileref, char *cptr, char *fnam, int flag) { int32 c; uint32 org; t_stat r; char gbuf[CBUFSIZE]; if (*cptr != 0) { /* more input? */ cptr = get_glyph (cptr, gbuf, 0); /* get origin */ org = get_uint (gbuf, 8, AMASK, &r); if (r != SCPE_OK) return r; if (*cptr != 0) /* no more */ return SCPE_ARG; } else org = 0200; /* default 200 */ for (;;) { /* until EOF */ while ((c = getc (fileref)) == 0) ; /* skip starting 0's */ if (c == EOF) /* EOF? done */ break; for ( ; c != 0; ) { /* loop until ctl = 0 */ /* ign ctrl frame */ if ((c = getc (fileref)) == EOF) /* get high byte */ return SCPE_FMT; /* EOF is error */ if (!MEM_ADDR_OK (org)) return SCPE_NXM; M[org] = ((c & 0377) << 8); /* store high */ if ((c = getc (fileref)) == EOF) /* get low byte */ return SCPE_FMT; /* EOF is error */ M[org] = M[org] | (c & 0377); /* store low */ org = org + 1; /* incr origin */ if ((c = getc (fileref)) == EOF) /* get ctrl frame */ return SCPE_OK; /* EOF is ok */ } /* end block for */ if (!(sim_switches & SWMASK ('C'))) return SCPE_OK; } /* end tape for */ return SCPE_OK; }
void GlyphCache::draw_text(FontEngine *font_engine, Canvas &canvas, float xpos, float ypos, const std::string &text, const Colorf &color) { std::string::size_type string_length = text.length(); if (string_length==0) { return; } RenderBatchTriangle *batcher = canvas.impl->batcher.get_triangle_batcher(); GraphicContext &gc = canvas.get_gc(); // Scan the string UTF8_Reader reader(text.data(), text.length()); while(!reader.is_end()) { unsigned int glyph = reader.get_char(); reader.next(); Font_TextureGlyph *gptr = get_glyph(font_engine, gc, glyph); if (gptr == NULL) continue; if (!gptr->texture.is_null()) { float xp = xpos + gptr->offset.x; float yp = ypos + gptr->offset.y; Rectf dest_size(xp, yp, Sizef(gptr->geometry.get_size())); if (enable_subpixel) { batcher->draw_glyph_subpixel(canvas, gptr->geometry, dest_size, color, gptr->texture); }else { batcher->draw_image(canvas, gptr->geometry, dest_size, color, gptr->texture); } } xpos += gptr->increment.x; ypos += gptr->increment.y; } }
void CL_GlyphCache::draw_text(CL_FontEngine *font_engine, CL_GraphicContext &gc, float xpos, float ypos, const CL_StringRef &text, const CL_Colorf &color) { CL_String::size_type string_length = text.length(); if (string_length==0) { return; } CL_RenderBatcherSprite *batcher = gc.impl->current_internal_batcher; // Scan the string CL_UTF8_Reader reader(text); while(!reader.is_end()) { unsigned int glyph = reader.get_char(); reader.next(); CL_Font_TextureGlyph *gptr = get_glyph(font_engine, gc, glyph); if (gptr == NULL) continue; if (!gptr->empty_buffer) { float xp = xpos + gptr->offset.x; float yp = ypos + gptr->offset.y; CL_Rectf dest_size(xp, yp, CL_Sizef(gptr->geometry.get_size())); if (enable_subpixel) { batcher->draw_glyph_subpixel(gc, gptr->geometry, dest_size, color, gptr->subtexture.get_texture()); }else { batcher->draw_image(gc, gptr->geometry, dest_size, color, gptr->subtexture.get_texture()); } } xpos += gptr->increment.x; ypos += gptr->increment.y; } }
Size FontProvider_Sprite::get_text_size(GraphicContext &gc, const std::string &text) { int width = 0; UTF8_Reader reader(text.data(), text.length()); while(!reader.is_end()) { unsigned int glyph = reader.get_char(); reader.next(); Font_Sprite_Glyph *gptr = get_glyph(glyph); int glyph_width; if (gptr) { glyph_width = spr_glyphs.get_frame_size(gptr->sprite_index).width; } else { glyph_width = spacelen; } width += glyph_width; } int current_height; if (width == 0) { current_height = 0; } else { current_height = height; } return (Size(width, current_height)); }