Skip to content

Commit 9e64cab

Browse files
authored
Merge branch 'stevenlovegrove:master' into feature/ColourProvider
2 parents fc09cac + 840cb98 commit 9e64cab

File tree

6 files changed

+176
-105
lines changed

6 files changed

+176
-105
lines changed

components/pango_core/src/file_extension.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ ImageFileType FileTypeMagic(const unsigned char data[], size_t bytes)
225225

226226
ImageFileType FileType(const std::string& filename)
227227
{
228+
// file extension incase we need that as a hint
229+
const std::string ext = FileLowercaseExtention(filename);
230+
228231
// Check magic number of file...
229232
std::ifstream f(filename.c_str(), std::ios::binary );
230233
if(f.is_open()) {
@@ -234,13 +237,17 @@ ImageFileType FileType(const std::string& filename)
234237
if(f.good()) {
235238
ImageFileType magic_type = FileTypeMagic(magic, magic_bytes);
236239
if(magic_type != ImageFileTypeUnknown) {
240+
if(magic_type == ImageFileTypeTiff && ext == ".arw") {
241+
// Special case where we use the extension as well as magic string
242+
magic_type = ImageFileTypeArw;
243+
}
244+
237245
return magic_type;
238246
}
239247
}
240248
}
241249

242250
// Fallback on using extension...
243-
const std::string ext = FileLowercaseExtention(filename);
244251
return FileTypeExtension(ext);
245252
}
246253

components/pango_image/include/pangolin/image/image_io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ PANGOLIN_EXPORT
4444
TypedImage LoadImage(const std::string& filename);
4545

4646
PANGOLIN_EXPORT
47-
TypedImage LoadImage(const std::string& filename, const PixelFormat& raw_fmt, size_t raw_width, size_t raw_height, size_t raw_pitch);
47+
TypedImage LoadImage(const std::string& filename, const PixelFormat& raw_fmt, size_t raw_width, size_t raw_height, size_t raw_pitch, size_t offset = 0);
4848

4949
/// Quality \in [0..100] for lossy formats
5050
PANGOLIN_EXPORT

components/pango_image/src/image_io_packed12bit.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <algorithm>
12
#include <fstream>
23
#include <memory>
34

components/pango_image/src/image_io_raw.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ namespace pangolin {
66
TypedImage LoadImage(
77
const std::string& filename,
88
const PixelFormat& raw_fmt,
9-
size_t raw_width, size_t raw_height, size_t raw_pitch
9+
size_t raw_width, size_t raw_height, size_t raw_pitch, size_t offset
1010
) {
1111
TypedImage img(raw_width, raw_height, raw_fmt, raw_pitch);
1212

1313
// Read from file, row at a time.
1414
std::ifstream bFile( filename.c_str(), std::ios::in | std::ios::binary );
15+
bFile.seekg(offset);
1516
for(size_t r=0; r<img.h; ++r) {
1617
bFile.read( (char*)img.ptr + r*img.pitch, img.pitch );
1718
if(bFile.fail()) {

components/pango_opengl/include/pangolin/gl/glfont.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include <cstdio>
3333
#include <cstdarg>
34+
#include <unordered_map>
3435

3536
namespace pangolin {
3637

@@ -40,14 +41,14 @@ class PANGOLIN_EXPORT GlFont
4041
// Load GL Font data. Delay uploading as texture until first use.
4142
GlFont(const unsigned char* ttf_buffer, float pixel_height, int tex_w=512, int tex_h=512);
4243
GlFont(const std::string& filename, float pixel_height, int tex_w=512, int tex_h=512);
43-
GlFont(float pixel_height, int tex_w=512, int tex_h=512);
4444

4545
virtual ~GlFont();
4646

4747
// Generate renderable GlText object from this font.
4848
GlText Text( const char* fmt, ... );
4949

50-
GlText Text( const std::string& str );
50+
// Utf8 encoded string
51+
GlText Text( const std::string& utf8 );
5152

5253
inline float Height() const {
5354
return font_height_px;
@@ -62,19 +63,17 @@ class PANGOLIN_EXPORT GlFont
6263
// This can only be called once GL context is initialised
6364
void InitialiseGlTexture();
6465

65-
const static int FIRST_CHAR = 32;
66-
const static int NUM_CHARS = 96;
67-
6866
float font_height_px;
6967
float font_max_width_px;
7068

71-
int tex_w;
72-
int tex_h;
73-
unsigned char* font_bitmap;
69+
ManagedImage<unsigned char> font_bitmap;
7470
GlTexture mTex;
7571

76-
GlChar chardata[NUM_CHARS];
77-
GLfloat kern_table[NUM_CHARS*NUM_CHARS];
72+
using codepoint_t = uint32_t;
73+
using codepointpair_t = std::pair<codepoint_t, codepoint_t>;
74+
75+
std::map<codepoint_t, GlChar> chardata;
76+
std::map<codepointpair_t, GLfloat> kern_table;
7877
};
7978

8079
}

0 commit comments

Comments
 (0)