summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-03-21 17:57:33 +0100
committerTor Andersson <tor.andersson@artifex.com>2012-03-21 17:57:33 +0100
commit3960e9a02f4064422645b1e65230fe39708dd48f (patch)
tree18860fd8be44ef7bdcab056162d94f74aeff9a9f /ios
parent9a278ec1303231d24b0ba1abb8a934409f2cd73a (diff)
downloadmupdf-3960e9a02f4064422645b1e65230fe39708dd48f.tar.xz
Update iOS app.
Diffstat (limited to 'ios')
-rw-r--r--ios/Info.plist8
-rw-r--r--ios/MuPDF.xcodeproj/project.pbxproj8
-rw-r--r--ios/document.c99
-rw-r--r--ios/document.h20
-rw-r--r--ios/main.m7
5 files changed, 72 insertions, 70 deletions
diff --git a/ios/Info.plist b/ios/Info.plist
index 85213b7c..6afbcf12 100644
--- a/ios/Info.plist
+++ b/ios/Info.plist
@@ -19,15 +19,17 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>0.9.1</string>
+ <string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>0.9</string>
+ <string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
+ <key>UIPrerenderedIcon</key>
+ <true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
@@ -46,7 +48,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
- <key>UIPrerenderedIcon</key>
- <true/>
</dict>
</plist>
diff --git a/ios/MuPDF.xcodeproj/project.pbxproj b/ios/MuPDF.xcodeproj/project.pbxproj
index 73fe67c6..1c047a36 100644
--- a/ios/MuPDF.xcodeproj/project.pbxproj
+++ b/ios/MuPDF.xcodeproj/project.pbxproj
@@ -245,7 +245,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
- CODE_SIGN_IDENTITY = "iPhone Distribution";
+ CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -262,7 +262,7 @@
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- HEADER_SEARCH_PATHS = ..;
+ HEADER_SEARCH_PATHS = "../**";
INFOPLIST_FILE = Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
LIBRARY_SEARCH_PATHS = "$(inherited)";
@@ -279,7 +279,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
- CODE_SIGN_IDENTITY = "iPhone Distribution";
+ CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -289,7 +289,7 @@
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- HEADER_SEARCH_PATHS = ..;
+ HEADER_SEARCH_PATHS = "../**";
INFOPLIST_FILE = Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
LIBRARY_SEARCH_PATHS = "$(inherited)";
diff --git a/ios/document.c b/ios/document.c
index 7004d702..0fb077ad 100644
--- a/ios/document.c
+++ b/ios/document.c
@@ -164,71 +164,84 @@ draw_page(struct document *doc, int number, fz_device *dev, fz_matrix ctm, fz_co
fz_flush_warnings(doc->ctx);
}
-static int
-charat(fz_text_span *span, int idx)
+static fz_text_char
+textcharat(fz_text_page *page, int idx)
{
+ static fz_text_char emptychar = { {0,0,0,0}, ' ' };
+ fz_text_block *block;
+ fz_text_line *line;
+ fz_text_span *span;
int ofs = 0;
- while (span) {
- if (idx < ofs + span->len)
- return span->text[idx - ofs].c;
- if (span->eol) {
- if (idx == ofs + span->len)
- return ' ';
- ofs ++;
+ for (block = page->blocks; block < page->blocks + page->len; block++)
+ {
+ for (line = block->lines; line < block->lines + block->len; line++)
+ {
+ for (span = line->spans; span < line->spans + line->len; span++)
+ {
+ if (idx < ofs + span->len)
+ return span->text[idx - ofs];
+ /* pseudo-newline */
+ if (span + 1 == line->spans + line->len)
+ {
+ if (idx == ofs + span->len)
+ return emptychar;
+ ofs++;
+ }
+ ofs += span->len;
+ }
}
- ofs += span->len;
- span = span->next;
}
- return 0;
+ return emptychar;
+}
+
+static int
+charat(fz_text_page *page, int idx)
+{
+ return textcharat(page, idx).c;
}
static fz_bbox
-bboxat(fz_text_span *span, int idx)
+bboxat(fz_text_page *page, int idx)
{
- int ofs = 0;
- while (span) {
- if (idx < ofs + span->len)
- return span->text[idx - ofs].bbox;
- if (span->eol) {
- if (idx == ofs + span->len)
- return fz_empty_bbox;
- ofs ++;
- }
- ofs += span->len;
- span = span->next;
- }
- return fz_empty_bbox;
+ return fz_round_rect(textcharat(page, idx).bbox);
}
static int
-textlen(fz_text_span *span)
+textlen(fz_text_page *page)
{
+ fz_text_block *block;
+ fz_text_line *line;
+ fz_text_span *span;
int len = 0;
- while (span) {
- len += span->len;
- if (span->eol)
- len ++;
- span = span->next;
+ for (block = page->blocks; block < page->blocks + page->len; block++)
+ {
+ for (line = block->lines; line < block->lines + block->len; line++)
+ {
+ for (span = line->spans; span < line->spans + line->len; span++)
+ len += span->len;
+ len++; /* pseudo-newline */
+ }
}
return len;
}
static int
-match(fz_text_span *span, char *s, int n)
+match(fz_text_page *page, const char *s, int n)
{
- int start = n, c;
+ int orig = n;
+ int c;
while (*s) {
- s += chartorune(&c, s);
- if (c == ' ' && charat(span, n) == ' ') {
- while (charat(span, n) == ' ')
+ s += fz_chartorune(&c, (char *)s);
+ if (c == ' ' && charat(page, n) == ' ') {
+ while (charat(page, n) == ' ')
n++;
} else {
- if (tolower(c) != tolower(charat(span, n)))
+ if (tolower(c) != tolower(charat(page, n)))
return 0;
n++;
}
}
- return n - start;
+ return n - orig;
}
int
@@ -239,8 +252,9 @@ search_page(struct document *doc, int number, char *needle, fz_cookie *cookie)
if (strlen(needle) == 0)
return 0;
- fz_text_span *text = fz_new_text_span(doc->ctx);
- fz_device *dev = fz_new_text_device(doc->ctx, text);
+ fz_text_sheet *sheet = fz_new_text_sheet(doc->ctx);
+ fz_text_page *text = fz_new_text_page(doc->ctx, fz_empty_rect);
+ fz_device *dev = fz_new_text_device(doc->ctx, sheet, text);
draw_page(doc, number, dev, fz_identity, cookie);
fz_free_device(dev);
@@ -258,7 +272,8 @@ search_page(struct document *doc, int number, char *needle, fz_cookie *cookie)
}
}
- fz_free_text_span(doc->ctx, text);
+ fz_free_text_page(doc->ctx, text);
+ fz_free_text_sheet(doc->ctx, sheet);
return doc->hit_count;
}
diff --git a/ios/document.h b/ios/document.h
index 0003070e..b4555578 100644
--- a/ios/document.h
+++ b/ios/document.h
@@ -1,21 +1,5 @@
-#ifndef _DOCUMENT_H_
-#define _DOCUMENT_H_
-
-#ifndef _FITZ_H_
-#error "fitz.h must be included before document.h"
-#endif
-
-#ifndef _MUPDF_H_
-#error "mupdf.h must be included before document.h"
-#endif
-
-#ifndef _MUXPS_H_
-#error "muxps.h must be included before document.h"
-#endif
-
-#ifndef _MUCBZ_H_
-#error "mucbz.h must be included before document.h"
-#endif
+#ifndef DOCUMENT_H
+#define DOCUMENT_H
struct document
{
diff --git a/ios/main.m b/ios/main.m
index 2af4d537..f242aedf 100644
--- a/ios/main.m
+++ b/ios/main.m
@@ -167,9 +167,12 @@ static void releasePixmap(void *info, const void *data, size_t size)
static UIImage *newImageWithPixmap(fz_pixmap *pix)
{
- CGDataProviderRef cgdata = CGDataProviderCreateWithData(pix, pix->samples, pix->w * 4 * pix->h, releasePixmap);
+ unsigned char *samples = fz_pixmap_samples(ctx, pix);
+ int w = fz_pixmap_width(ctx, pix);
+ int h = fz_pixmap_height(ctx, pix);
+ CGDataProviderRef cgdata = CGDataProviderCreateWithData(pix, samples, w * 4 * h, releasePixmap);
CGColorSpaceRef cgcolor = CGColorSpaceCreateDeviceRGB();
- CGImageRef cgimage = CGImageCreate(pix->w, pix->h, 8, 32, 4 * pix->w,
+ CGImageRef cgimage = CGImageCreate(w, h, 8, 32, 4 * w,
cgcolor, kCGBitmapByteOrderDefault,
cgdata, NULL, NO, kCGRenderingIntentDefault);
UIImage *image = [[UIImage alloc]