MCPcopy Create free account
hub / github.com/creatale/node-dv / FindShape

Method FindShape

deps/tesseract/classify/shapetable.cpp:396–411  ·  view source on GitHub ↗

Returns the id of the shape that contains the given unichar and font. If not found, returns -1. If font_id < 0, the font_id is ignored and the first shape that matches the unichar_id is returned.

Source from the content-addressed store, hash-verified

394// If font_id < 0, the font_id is ignored and the first shape that matches
395// the unichar_id is returned.
396int ShapeTable::FindShape(int unichar_id, int font_id) const {
397 for (int s = 0; s < shape_table_.size(); ++s) {
398 const Shape& shape = GetShape(s);
399 for (int c = 0; c < shape.size(); ++c) {
400 if (shape[c].unichar_id == unichar_id) {
401 if (font_id < 0)
402 return s; // We don't care about the font.
403 for (int f = 0; f < shape[c].font_ids.size(); ++f) {
404 if (shape[c].font_ids[f] == font_id)
405 return s;
406 }
407 }
408 }
409 }
410 return -1;
411}
412
413// Returns the first unichar_id and font_id in the given shape.
414void ShapeTable::GetFirstUnicharAndFont(int shape_id,

Callers 2

AddSampleMethod · 0.80
BuildFromShapeMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected